home *** CD-ROM | disk | FTP | other *** search
- /*
- * debug.c - routines to help with debugging
- */
-
- #include "RevRdist.h"
- #include <TransSkelProto.h>
-
- static DialogPtr dbgDialog;
- static Boolean saveflags = false; /* true to save Flags */
-
- static void dbgEvent (Integer, EventRecord *);
- static void dbgClose (void);
- static void dbgClobber (void);
- static void dbgWatch (void);
-
- /*
- *=========================================================================
- * setDebug () - set debug flags via modeless dialog
- * entry: SkelInit called, but not SkelMain
- * exit: Flags set
- *=========================================================================
- */
- void
- setDebug ()
- {
- register Integer itemNo; /* index to dialog items */
- Integer itemType; /* for GetDItem call */
- Handle item; /* " */
- Rect r; /* " */
- Integer val; /* value of individual flag bits */
-
- saveflags = false;
- dbgDialog = GetNewDialog (RSRC_BASE+WIND_DFLAGS, nil, (WindowPtr) -1L);
- if (dbgDialog == nil)
- return;
- SkelDialog (dbgDialog, dbgEvent, dbgClose, dbgClobber);
- /*
- * Preset check boxes based on current Flag bit settings
- */
- for (itemNo = 3; itemNo < 3 + 31; itemNo++)
- {
- itemType = -1;
- GetDItem (dbgDialog, itemNo, &itemType, &item, &r);
- if (itemType == (chkCtrl | ctrlItem))
- {
- val = (Flags >> (itemNo - 3)) & 1;
- SetCtlValue ((ControlHandle) item, val);
- }
- }
- ShowWindow ((WindowPtr) dbgDialog);
- SkelBackground (dbgWatch);
- SkelMain ();
- }
-
-
-
- /*
- *=========================================================================
- * dbgClobber () - get rid of the debug dialog resources
- *=========================================================================
- */
- void
- dbgClobber ()
- {
- if (dbgDialog)
- DisposDialog (dbgDialog);
- dbgDialog = nil;
- SkelWhoa ();
- }
-
-
- /*
- *=========================================================================
- * dbgClose () - exit the debug dialog
- * entry: saveflags true if Flags final value should be rewritten to
- * resource in ourselves.
- * exit: Flags set based on final control setting in dialog
- *=========================================================================
- */
- void
- dbgClose ()
- {
- Handle h; /* ptr to flags resource */
- Integer itemNo; /* dialog item number */
- Integer itemType; /* dialog item type */
- Handle item; /* dialog item */
- Rect r; /* needed for GetDItem */
- Integer val;
-
- Flags = 0;
- for (itemNo = 3; itemNo < 3 + 31; itemNo++)
- {
- itemType = -1;
- GetDItem (dbgDialog, itemNo, &itemType, &item, &r);
- if (itemType == (chkCtrl | ctrlItem))
- {
- val = GetCtlValue ((ControlHandle) item);
- Flags |= val << (itemNo - 3);
- }
- }
- SkelRmveDlog (dbgDialog);
- if (saveflags)
- {
- UseResFile (Ap_refNum);
- h = Get1Resource (TYPE_LONG, FLAG_PARM);
- if (h)
- {
- if (GetHandleSize (h) >= sizeof (Flags))
- {
- BlockMove ((Ptr) &Flags, *h, sizeof (Flags));
- ChangedResource (h);
- WriteResource (h);
- }
- ReleaseResource (h);
- }
- saveflags = false;
- }
- }
-
-
- /*
- *=========================================================================
- * dbgEvent (itemNo, theEvent) - handle events in debug dialog
- * entry: itemNo = the item number in dialog
- * theEvent = ptr to event record significant to dialog
- *=========================================================================
- */
- void
- dbgEvent (itemNo, theEvent)
- Integer itemNo;
- EventRecord * theEvent;
- {
- Integer itemType; /* dialog item type */
- Handle item; /* dialog item structure */
- Rect r; /* needed for GetDItem */
- Integer val; /* control value */
- Longint l; /* temp long value */
-
- saveflags = (itemNo == 2);
- if (itemNo == 1 || itemNo == 2)
- {
- /*
- * Okay button pushed, close dialog
- */
- dbgClose ();
- return;
- }
- /*
- * The only other thing we are interested in is mouse downs in
- * controls
- */
- if (theEvent->what == mouseDown && itemNo > 1)
- {
- itemType = -1;
- GetDItem (dbgDialog, itemNo, &itemType, &item, &r);
- if (itemType == (chkCtrl | ctrlItem))
- {
- val = GetCtlValue ((ControlHandle) item);
- SetCtlValue ((ControlHandle) item, !val);
- }
- }
- }
-
-
- /*
- *=========================================================================
- * dbgWatch () - watch for Quit
- *=========================================================================
- */
- void
- dbgWatch ()
- {
- if (Quit)
- {
- SkelBackground (nil);
- dbgClose ();
- }
- }
-